<!DOCTYPE html>
<html lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>测试json数据格式</title>
</head>
<body>
  <script type="text/javascript">
      //json对象
      var json1 = {id:1, name:'张三', age: 18};

      //json字符串
      var str = JSON.stringify(json1);

      //json格式字符串转json对象
      var objJson = JSON.parse(str);

      alert(json1);
      alert(str);
  </script>
</body>
</html>